home *** CD-ROM | disk | FTP | other *** search
- /* strchr.c From TC Bible page 275 Use strchr to find the first
- occurence of a particular character in a given string. */
-
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- main()
- {
- int c;
- char buf[80], *result;
- printf("Enter a string: ");
- gets(buf);
- printf("Enter a character to be located (first occurrence):");
- c = getche();
- if ((result = strchr(buf, c)) == NULL)
- {
- printf("\n'%c' <-- not in \"%s\"\n", c, buf);
- }
- else
- {
- printf("\n'%c' first occurs at: %s\n",c, result);
- }
- }